ImageGear Professional v18.2 > User Guide > Getting Started > Using Recognition Component |
The following tutorial provides step-by-step instructions on how to create a simple application that loads and recognizes images and saves the recognized data into the file in the specified output format.
Before completing the tutorial steps, complete the preliminary steps outlined in this section.
The following necessary binaries must be located in the working directory of the application or in the directory being specified by the system path:
Recognition re-distributable package (see Distributing Recognition Engine Files with Your Application)
igcore17d.dll must be linked to the application using igcore17d.lib or any other appropriate way. Other dlls do not need to be linked.
The following header files must be included into the code:
C |
Copy Code
|
---|---|
#include "gear.h" // Include for ImageGear Core #include "i_rec.h" // Include for ImageGear Recognition component |
Note that all other ImageGear header files that are referenced from these two must be accessible.
C |
Copy Code
|
---|---|
AT_ERRCOUNT nErrCount; HIGEAR hIGear; HIG_REC_IMAGE hRecImg; AT_INT i; enumIGRecLangEnable lang[IG_REC_LANG_SIZE]; HIG_REC_DOCUMENT hDocument; /* To unlock the toolkit for deployment you must call the IG_lic_solution_name_set, IG_lic_solution_key_set() and possibly the IG_lic_OEM_license_key_set() functions. See Licensing section in ImageGear User Manual for more details. */ // Attach LZW component (if necessary) IG_comm_comp_attach( "LZW" ); // Attach Recognition component nErrCount = IG_comm_comp_attach( "REC" ); if(nErrCount != 0) { return -1; } |
C |
Copy Code
|
---|---|
nErrCount = IG_REC_initialize(); if(nErrCount != 0) { return -1; } |
C |
Copy Code
|
---|---|
nErrCount = IG_load_file("..\\RecognitionC\\Image.tif", &hIGear ); if(nErrCount != 0) { IG_REC_close(); return -1; } nErrCount = IG_REC_image_import(hIGear, &hRecImg); // HIGEAR can be deleted now IG_image_delete(hIGear); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return - 1; } |
C |
Copy Code
|
---|---|
// Disable all languages for(i = 0; i < IG_REC_LANG_SIZE; i ++) { lang[i] = IG_REC_LANG_DISABLED; } // Enable English and French lang[IG_REC_LANG_ENG] = IG_REC_LANG_ENABLED; lang[IG_REC_LANG_FRE] = IG_REC_LANG_ENABLED; // Set English and French recognition languages nErrCount = IG_REC_languages_set(lang); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return - 1; } |
C |
Copy Code
|
---|---|
// Preprocess the image nErrCount = IG_REC_image_preprocess(hRecImg); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return - 1; } // Recognize the image nErrCount = IG_REC_image_recognize(hRecImg); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return - 1; } |
C |
Copy Code
|
---|---|
// Set Word2000 output format nErrCount = IG_REC_output_format_set("Converters.Text.Word2000"); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return - 1; } // Set Windows ANSI code page nErrCount = IG_REC_output_codepage_set("Windows ANSI"); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return - 1; } // Set True Page output level nErrCount = IG_REC_output_level_set(IG_REC_OL_TRUEPAGE); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return; } |
C |
Copy Code
|
---|---|
// Create a document nErrCount = IG_REC_document_create(NULL, &hDocument); if(nErrCount != 0) { IG_REC_image_delete(hRecImg); IG_REC_close(); return; } // Insert a page into the document. // Note that after inserting the page does not require to be deleted. nErrCount = IG_REC_document_page_insert(hDocument, hRecImg, -1); if(nErrCount != 0) { IG_REC_document_close(hDocument); IG_REC_image_delete(hRecImg); IG_REC_close(); return; } // Save a document into the file in Word2000 format (being set above) IG_REC_document_write(hDocument, "Tutorial.DOC"); // Close document IG_REC_document_close(hDocument); |
C |
Copy Code
|
---|---|
IG_REC_close(); |
Recognition Component API Reference